package com.newtouch.bxzs.database.synchronize.mapper.achievement;

import com.newtouch.bxzs.database.synchronize.model.achievement.AchievementPolicyVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 * 业绩保单级Mapper
 *
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2021/1/6 14:34</td>
 * <td>Amour</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author yuanjie
 * @version 1.0.0
 * @since 1.0.0
 */
@Mapper
public interface AchievementPolicyMapper {

    /**
     * 批量添加业绩保单级数据
     * @param achievementPolicy
     * @param createTime
     * @return
     */
    @Insert({"<script>insert into ASSISTANT_USER_POLICY_ACHIEVEMENT(USER_POLICY_ACHIEVEMENT_ID," +
            "CREATE_USER_ID,CREATE_TIME,USER_JOB_NUMBER,POLICY_NUMBER,SCALE_PREMIUM," +
            "ACHIEVEMENT_PERSONAL,DATA_SOURCE) values" +
            "<foreach collection='list' item='item' separator=',' >" +
            "(REPLACE(uuid(),'-','')," +
            "'admin',#{createTime},#{item.userJobNumber},#{item.policyNumber}," +
            "#{item.scalePremium},#{item.achievementPersonal},#{item.dataSource})" +
            "</foreach>" +
            "ON DUPLICATE KEY UPDATE" +
            " UPDATE_USER_ID = values(CREATE_USER_ID)</script>"})
    int addAchievementPolicy(@Param("list") List<AchievementPolicyVO> achievementPolicy, @Param("createTime") Date createTime);
}
